<?php
class TTT_Myfilter_Model_Entity
{
	const PRODUCT 	= 'product';
	const CUSTOMER 	= 'customer';
	const ORDER 	= 'order';
	const INVOICE 	= 'invoice';
	const SHIPMENT 	= 'shipment';

	const PRODUCT_GRID_URL		= 'adminhtml/catalog_product/index';
	const CUSTOMER_GRID_URL 	= 'adminhtml/customer/index';
	const ORDER_GRID_URL 		= 'adminhtml/sales_order/index';
	const INVOICE_GRID_URL 		= 'adminhtml/sales_invoice/index';
	const SHIPMENT_GRID_URL 	= 'adminhtml/sales_shipment/index';

	private $_availableEntities = array(
		self::CUSTOMER => 'Customer',
		self::PRODUCT => 'Product',
		self::ORDER => 'Order',
		self::INVOICE => 'Invoice',
		self::SHIPMENT => 'Shipment',
	);

	protected $_filter;




	public function getOptionArray()
	{
		return $this->_availableEntities;
	}


	public function getUrl()
	{
		$entity = $this->_filter->entity;
		$filterKey = $this->_filter->filterkey;
		$filterValue = $this->_filter->filtervalue;
		$url = '';
		switch ($entity) {
			case self::PRODUCT:
				$url = self::PRODUCT_GRID_URL;
				break;
			case self::CUSTOMER:
				$url = self::CUSTOMER_GRID_URL;
				break;
			case self::ORDER:
				$url = self::ORDER_GRID_URL;
				break;
			case self::INVOICE:
				$url = self::INVOICE_GRID_URL;
				break;
			case self::SHIPMENT:
				$url = self::SHIPMENT_GRID_URL;
				break;
		}

		return Mage::helper("adminhtml")
				->getUrl($url,
					array(
						$filterKey => $filterValue
					));

	}

	public function setFilter($filter)
	{
		$this->_filter = $filter;
		return $this;
	}
}